let curUser

let connectSocketInit = function() {
	// 创建websocket连接
	uni.connectSocket({
		url: "ws://127.0.0.1:8888?userid="+uni.getStorageSync("userid"),   //wss协议链接地址
		success(res) {
			console.log("websocket连接成功");
		}
	});
	//监听WebSocket连接打开事件
	uni.onSocketOpen(function(res) {
		uni.showToast({
			title:"WebSocket连接已打开！",
			icon:"none"
		})
	})
	// 监听websocket链接关闭
	uni.onSocketClose(function (res) {
		curUser = null
		console.log('WebSocket close.');
		console.log(res)
	});
}

/*导出*/
export default {
	connectSocketInit
}
